import collections
import bisect


class Solution(object):
    def countRectangles(self, rectangles, points):
        d = collections.defaultdict(list)
        for l, h in rectangles:
            d[h].append(l)
        for h in d:
            d[h].sort()
        m = len(points)
        ans = [0] * m
        for i, (x, y) in enumerate(points):
            for h in range(y, 101):
                if d[h]:
                    ans[i] += len(d[h]) - bisect.bisect_left(d[h], x)
        return ans


data = Solution()
rectangles = [[1, 1], [2, 2], [3, 3]]
points = [[1, 3], [1, 1]]
print(data.countRectangles(rectangles, points))
